package com.gcd;

import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.content.Context;

public class DatabaseHelper extends SQLiteOpenHelper {
	private static final String DATABASE_NAME = "relasi3.db";
	public static final String ID = "id";
	public static final String NAMA = "nama";
	public static final String NILAI = "nilai";
	
	
	public DatabaseHelper(Context context){
		super(context, DATABASE_NAME, null, 1);
	}
	
	public void onCreate(SQLiteDatabase db){
		db.execSQL("CREATE TABLE relasi (id INTEGER PRIMARY KEY, nama TEXT, nilai FLOAT );");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (1,'SatuP',0.5);");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (2,'NP',0.667);");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (3,'AnakL',1.0);");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (4,'AnakP',2.0);");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (5,'IstriAnakYes',0.125);");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (6,'IstriAnakNo',0.25);");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (7,'SuamiAnakYes',0.25);");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (8,'SuamiAnakNo',0.5);");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (9,'AyahYesIbuYes',0.2);");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (10,'AyahYesIbuNo',0.167);");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (11,'AyahNoIbuYes',0.167);");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (12,'AyahYesIbuYesSdrYes',0.167);");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (13,'AyahNoIbuYesSdrYes',0.167);");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (14,'AyahYesIbuYesSdrNo',0.333);");
		db.execSQL("INSERT INTO RELASI (id, nama, nilai) values (15,'AyahNoIbuYesSdrNo',0.333);");
	}
	
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
		android.util.Log.w("Constants",
				"Upgrading database which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS relasi");
		onCreate(db);
	}
}
